package forum.repository;

import forum.domain.Resources;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Administrator on 2017/4/1.
 */
public interface ResourcesRepository extends JpaRepository<Resources, Integer>, JpaSpecificationExecutor<Resources> {

    List<Resources> findByResourcesname(String name);

    List<Resources> findByParentid(Integer id);

    @Transactional
    @Modifying
    @Query(value ="delete from role_resources where role_resources.resourcesid = ?1", nativeQuery = true)
    void deleteByResourcesid(Integer id);



}
